//
// Created by 86131 on 2023/9/24.
//
#include <istream>
#include <iostream>
using namespace std;
int main(){
    int a[10000];
    int n;
    int sum=0;
    int maxsum=0;
    cin>>n;
    while(n!=0){
        sum+=n;
        if(sum>maxsum){maxsum = sum;
        }else if(sum<0){sum = 0;}
        cin>>n;
    }
    cout<<maxsum;
}